package com.food;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.database.DataCon;
import com.userinfo.UserBean;


public class FoodInfoAction {
	String sqlstr;
	String rsString;
	//String str2;
    Connection con=null;
	Statement stmt2=null;
	ResultSet rs=null;
	DataCon dt = new DataCon();
	
	public List<FoodInfoAction> FoodInfoAction(int i)throws SQLException{
		con = dt.DbConn();
		stmt2 = con.createStatement();  
		sqlstr = "select * from foodinfo where foodClassId = "+ i;
		System.out.println(sqlstr);
		rs = stmt2.executeQuery(sqlstr);
		List foodList=new ArrayList();
		while(rs.next()){
			HashMap hm =new HashMap();
			hm.put("fname",rs.getString("foodName"));
			hm.put("fid",rs.getInt("foodId"));
			foodList.add(hm);
		}
		rs.close();
		stmt2.close();
		con.close();
		return foodList;
	}
	
	public List<FoodInfoAction> SFoodInfoAction(int i)throws SQLException{
		con = dt.DbConn();
		stmt2 = con.createStatement();   
		sqlstr = "select * from foodinfo where foodId = "+ i;
		System.out.println(sqlstr);
		rs = stmt2.executeQuery(sqlstr);
		List foodList2=new ArrayList();
		while(rs.next()){
			System.out.println(rs.getString("foodName"));
			FoodInfoBean fw=new FoodInfoBean();
			fw.setFoodNum(rs.getInt("foodNum"));
			fw.setFoodName(rs.getString("foodName"));
			foodList2.add(fw);
		}
		rs.close();
		stmt2.close();
		con.close();
		return foodList2;
	}
	

}
